<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUserAddressesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_addresses', function (Blueprint $table) {
            $table->id()->comment('用户地址表');
            $table->integer('user_id')->comment('用户的id')->index();
            $table->string('consignee_name',50)->comment('收货人姓名');
            $table->char('phone',15)->comment('收货人电话');
            $table->string('province',100)->comment('收货人所在省');
            $table->string('city',100)->comment('收货人所在市');
            $table->string('district',150)->comment('收货人所在区');
            $table->integer('city_id')->comment('收货人城市的id')->index();
            $table->string('detail',1000)->comment('收货人详细地址');
            $table->string('post_code',50)->nullable()->comment('邮编');
            $table->string('longitude',20)->nullable()->comment('经度');
            $table->string('latitude',20)->nullable()->comment('纬度');
            $table->integer('is_default')->default(0)->comment('是否为默认 0:不为默认 1为默认')->index();
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_addresses');
    }
}
